package cn.how2go.api.service.impl;

import cn.how2go.api.entity.Person;
import cn.how2go.api.entity.UserInfo;
import cn.how2go.api.mapper.PersonMapper;
import cn.how2go.api.mapper.UserInfoMapper;
import cn.how2go.api.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    @Autowired
    private PersonMapper personMapper;

    @Override
    public List<UserInfo> listUserInfo() {
        return userInfoMapper.listUserInfo();
    }

    @Override
    public List<UserInfo> listUserInfos(String ids) {
        String[] arrId = ids.split(",");
        String param = "'";
        for(String id:arrId){
            param+=id+"','";
        }
        param+="0'";
        return userInfoMapper.listUserInfos(param);
    }

    @Override
    public Person selectUserInfoOnce(String id) {
        return personMapper.selectById(id);
    }
}
